<?php namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Category;
use App\Models\Live;
use App\Utils\ReturnUtils;

class LiveController extends Controller
{
    //获取直播分类
    public function getCategoryLive(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new Category())->getCategoryLive();
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'], $data);
    }
    //获取直播列表
    public function getLiveList(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new Live($request))->getLiveList();
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'],$data['data'], $data['paging']);
    }
    //获取机构用户直播列表
    public function getUserLiveList(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new Live($request))->getUserLiveList();
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'],$data['data'], $data['paging']);
    }
    
    //直播详情
    public function getLiveDetail(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new Live($request))->getLiveDetail();
        if(!$data){
            return $returnUtils->returnError($returnUtils->return['ERROR_SOME_GET']);
        }
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'], $data);
    }
    
    //精选页面
    public function getChosen(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new Live($request))->getChosen();
        if(!$data){
            return $returnUtils->returnError($returnUtils->return['ERROR_SOME_GET']);
        }
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'], $data);
    }
    
    //获取轮播
    public function getLunboLive(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new Live($request))->getLunboLive();
        if(!$data){
            return $returnUtils->returnError($returnUtils->return['ERROR_SOME_GET']);
        }
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'], $data);
    }
    
    //获取相关推荐
    public function getRecommendLive(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new Live($request))->getRecommendLive();
        if(!$data){
            return $returnUtils->returnError($returnUtils->return['ERROR_SOME_GET']);
        }
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'], $data['data'], $data['paging']);
    }
    
    //预定节目
    public function bookLive(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new Live($request))->bookLive();
        if(!$data){
            return $returnUtils->returnError($returnUtils->return['ERROR_SOME_GET']);
        }
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'], $data['data'], $data['paging']);
    }
}
